#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define mid (l+r>>1LL)
#define rep(x,y,z) for(int x=(y);x<=(z);x++)
#define per(x,y,z) for(int x=(y);x>=(z);x--)
#define repn(x) rep(x,1,n)
#define repm(x) rep(x,1,m)
#define e(x) for(int i=h[x],y=to[i];i;i=nxt[i],y=to[i])
#define E(x) for(auto y:p[x])
#define Pi pair<int,int>
#define pb push_back
#define ui unsigned ll
inline int read(){int s=0,w=1;char c=getchar();while(c<48||c>57){if(c=='-')w=-1;c=getchar();}while(c>=48&&c<=57)s=(s<<1)+(s<<3)+c-48,c=getchar();return s*w;}
const int N=1e5+5,M=2e6+5,inf=(1LL<<30)-1,mod=1e9+7;
const ll llf=1e18;
inline void add(int &a,int b){((a+=b)>=mod) and (a-=mod);}
inline int Add(int a,int b){return add(a,b),a;}
inline void red(int &a,int b){add(a,mod-b);}
inline int Red(int a,int b){return red(a,b),a;}
inline int mul(int a,int b){return 1LL*a*b%mod;}
inline void Mul(int &a,int b){a=mul(a,b);}
inline int qp(int a,int b){if(!b)return 1;int c=qp(a,b>>1);Mul(c,c);if(b&1)Mul(c,a);return c;}
inline int INV(int x){return qp(x,mod-2);}
bool S;
int n,h[N],to[N<<1],nxt[N<<1],cnt,A,B,st,dep[N],siz[N],dfn[N],Time,s[N],tp,f[N],Id[N],deg[N];
inline void add_(int a,int b){
	to[++cnt]=b,nxt[cnt]=h[a],h[a]=cnt,deg[a]++;
}
struct node{
	int son,y;
};
vector<node>p[N];
vector<int>d[N];//dis=A's 
int Mn[3005][3005],tt[3005][3005];
inline void dfs(int x,int fa){
	dep[x]=dep[fa]+1,siz[x]=1,Id[dfn[x]=++Time]=x,s[++tp]=x;
	rep(i,0,n)Mn[x][i]=x;
	if(tp>A)p[s[tp-A]].pb({s[tp-A+1],x});
	rep(i,max(1,tp-B),tp-1)Mn[s[i]][s[i+1]]=min(Mn[s[i]][s[i+1]],x),Mn[s[i]][0]=min(Mn[s[i]][0],x);
	rep(i,1,tp-1)tt[s[i]][x]=s[i+1];
	e(x)if(y^fa)dfs(y,x),siz[x]+=siz[y];
	tp--;
}
int Dep[N];
inline void Dfs(int x,int fa,int rt){
	Dep[x]=Dep[fa]+1;
	if(Dep[x]<=B+1)d[rt].pb(x);
	e(x)if(y^fa)Dfs(y,x,rt);
}
int dp[3005][3005],g[3005][3005];
inline void dfs_dp(int x,int fa){
	int ctt=0,sz;
	vector<int>q;
	e(x)if(y^fa)dfs_dp(y,x),q.pb(y);
	sz=(int)q.size();
	E(x){
		int son=y.son,t=y.y,W=n+1;
		for(auto z:d[t]){
			
			if(dfn[z]>=dfn[t]&&dfn[z]<dfn[t]+siz[t]){
				W=min(W,dp[z][0]);//z in subtree(t)
				// if(x==46)cerr<<dp[z][0]<<'\n';
			}
			else if(dfn[t]>=dfn[z]&&dfn[t]<dfn[z]+siz[z]){
				W=min(W,dp[z][tt[z][t]]);//t in subtree(z)
			}
			else W=min(W,dp[z][0]);
		}
		if(!g[x][son])ctt++;
		g[x][son]=max(g[x][son],W),dp[x][0]=max(dp[x][0],W);
	}
	if(!ctt){
		dp[x][0]=Mn[x][0];
		int MN=x;
		rep(i,0,sz-1){
			int y=q[i];
			dp[x][y]=MN,MN=min(MN,Mn[x][y]);
		}
		MN=x;
		per(i,sz-1,0){
			int y=q[i];
			dp[x][y]=min(dp[x][y],MN),MN=min(MN,Mn[x][y]);
		}
		return;
	}
	if(ctt==1){
		int MN=x;
		e(x)if(y!=fa&&!g[x][y])MN=min(MN,Mn[x][y]),dp[x][y]=dp[x][0];
		dp[x][p[x][0].son]=MN;
		return;
	}
	int Mx=0;
	e(x)if(y^fa){
		dp[x][y]=Mx;
		Mx=max(Mx,g[x][y]);
	}
	Mx=0;
	per(i,sz-1,0){
		int y=q[i];
		dp[x][y]=max(dp[x][y],Mx),Mx=max(Mx,g[x][y]);
	}
}
inline void ddd(int x,int fa){
	dep[x]=dep[fa]+1,Id[dep[x]]=x;
	e(x)if(y^fa)ddd(y,x);
}
int sp[N],Sp[N];
int vA[N];
inline void subtaskspe(){
	ddd(st,0);
	if(A==n){
		int ans=n;
		rep(i,1,min(n,B+1))ans=min(ans,Id[i]);
		cout <<ans;
		return;
	}
	vA[1+A]=1,vA[2+A]=-1;
	repn(i){
		vA[i]+=vA[i-1];
		int l,r;
		if(vA[i]){
			l=i+A,r=min(i+A+B,n);
			if(l<=n)vA[l]++,vA[r+1]--;
			else {
				sp[i]++,sp[min(n+1,i+B+1)]--;
			}
			l=i,r=min(i+B,n);
			Sp[l]++,Sp[r+1]--;
			l=max(1,i-B),r=i-1;
			if(l<=r)sp[l]++,sp[r+1]--;
		}
	}
	int ans=n;
	repn(i){
		Sp[i]+=Sp[i-1];
		if(Sp[i]){
			if(i+A>n){
				int l=i,r=min(n,i+B);
				sp[l]++,sp[r+1]--;
			}
		}
	}
	repn(i){
		sp[i]+=sp[i-1];
		if(sp[i])ans=min(ans,Id[i]);
	}
	cout <<ans;
}
inline void Main(){
	n=read(),st=read(),A=read(),B=read();
	rep(i,2,n){
		int x=read(),y=read();
		add_(x,y),add_(y,x);
	}
	if(A<=B)return puts("1"),void();
	bool fl=deg[st]==1;
	repn(i)fl&=deg[i]<=2;
	if(fl)return subtaskspe();
	dfs(st,0);
	repn(x)Dfs(x,0,x);
	dfs_dp(st,0);
	cout <<dp[st][0];
}
bool E;
signed main(){
	freopen("nim.in","r",stdin);
	freopen("nim.out","w",stdout);
	// cerr<<"[Memory]"<<(&S-&E)/1024/1024<<"MB.\n";
	int T=1;
	while(T--)Main();
	return 0;
}